package com.chinaisafe.user.vo.request;

import com.chinaisafe.base.common.vo.request.PageReqVo;
import com.chinaisafe.base.common.validated.UpdateGroup;
import com.chinaisafe.user.entity.SysAccount;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.io.Serial;
import java.io.Serializable;

/**
 * SysAccountReqVO
 * Description：账号请求值对象
 *
 * @author xuefu.shu
 * @date  2024-07-13 13:31:45
 */
@Getter
@Setter
@ToString
@Accessors(chain = true)
@Schema(name = "SysAccountReqVO", description = "账号请求值对象")
public class SysAccountReqVO extends PageReqVo implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @Schema(description = "主键id")
    @NotNull(groups = UpdateGroup.class, message = "主键id不能为空" )
    private Long id;

    @Schema(description = "乐观锁版本")
    private Integer version;

    @Schema(description = "手机号")
    private String mobile;

    @Schema(description = "密码")
    private String password;

    @Schema(description = "微信openid")
    private String wxOpenid;

    @Schema(description = "用户类别")
    private Integer userType;

    @Schema(description = "主租户")
    private String mainTenantCode;

    @Schema(description = "是否第一次登录")
    private Boolean firstLogin;

    @Schema(description = "网关路由标记")
    private String nodeLabel;


    /**
     * 将请求值对象装换为实体
     * @return SysAccount
     * @author xuefu.shu
     * @date 2024-07-13 13:31:45
     */
    public SysAccount convertToEntity() {
        SysAccount entity = new SysAccount();
        entity.setId(this.id);
        entity.setVersion(this.version);
        // 给实体对应的字段赋值 可根据实际业务删减
        entity.setMobile(this.mobile);
        entity.setPassword(this.password);
        entity.setWxOpenid(this.wxOpenid);
        entity.setUserType(this.userType);
        entity.setMainTenantCode(this.mainTenantCode);
        entity.setFirstLogin(this.firstLogin);
        entity.setNodeLabel(this.nodeLabel);
        return entity;
    }
}
